namespace AltNetUK.Models.Inputs
{
    using System;
    using System.Globalization;
    using System.Text;

    public sealed class CheckBox : Input
    {
        public override string Type
        {
            get
            {
                return "checkbox";
            }
        }

        public string Render(int tabIndex, bool value, bool disabled)
        {
            if (1 > tabIndex)
            {
                throw new ArgumentOutOfRangeException("tabIndex");
            }

            StringBuilder buffer = new StringBuilder();

            buffer.AppendFormat(
                CultureInfo.InvariantCulture,
                "<input id='{0}' name='{1}' tabindex='{2}' title='{3}' type='checkbox'{4}{5} />",
                this.Id,
                this.Name,
                tabIndex,
                this.Title,
                (value) ? " checked='checked'" : string.Empty,
                (disabled) ? " disabled='disabled'" : string.Empty
                );
            buffer.Append(new Label(this, value ? "checked" : string.Empty, disabled));

            return buffer.ToString();
        }

        public override ValidationResult Validate(string value)
        {
            return new ValidationResult();
        }
    }
}